<template>
    <view class="friend-wrap">
        <view class="check-box" v-if="isShowCheck">
            <i class="iconfont icon-weixuanzhong" v-if="friend.is_check == false"></i>
            <i :class="'iconfont icon-xuanzhong' + (friend.disabled ? ' disabled': '')" v-else></i>
        </view>
        <view class="image-box">
            <image
                :src="friend.info.avatar_url ? global.FILE_DOMAIN + friend.info.avatar_url : '/static/images/default_avatar.png'"
            />
        </view>
        <text class="title-box">{{ friend.info.username }}</text>
    </view>
</template>

<script setup lang="ts">
import type { Friend } from '@/types/friend'
import { inject } from 'vue'

// 全局属性
const global: any = inject('global')

defineProps<{
    friend: Friend,
    isShowCheck?: boolean
}>()
</script>

<style lang="scss">
.friend-wrap {
    display: flex;
    align-items: center;
    .check-box {
        margin-right: 15rpx;
        .iconfont {
            font-size: 40rpx;
            color: #d4d4d4;
        }
        .icon-xuanzhong {
            color: $uni-color-primary;
        }
        .disabled {
            color: #d4d4d4;
        }
    }
    .image-box {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 90rpx;
        height: 90rpx;
        border-radius: 10rpx;
        border: 2rpx solid #d4d4d4;
        overflow: hidden;
        
        image {
            width: 80rpx;
            height: 80rpx;
        }
    }
    .title-box {
        flex: 1;
        margin-left: 30rpx;
        color: #000;
        font-size: 32rpx;
        border-bottom: 2rpx solid #EDEDED;
        padding: 50rpx 0;
    }
    &:last-child .title-box {
        border-bottom: none;
    }
}
</style>